package com.canbot.u05.activity.customvoice.tool

import android.app.Dialog
import android.content.Context
import android.graphics.Point
import android.os.Bundle
import android.view.View
import android.widget.Button

import com.canbot.u05.R

/**
 * CustomDialogSuccessView
 *
 * @author Liu.Heng
 * @date 2019/6/3
 */
class CustomDialogSuccessView(private val mContext: Context, private val listener: OnCloseListener?) : Dialog(mContext), View.OnClickListener {

    interface OnCloseListener {

        /***
         * 点击按钮回调
         * @param dialog  mContext
         * @param confirm true or false
         */
        fun onClick(dialog: Dialog, confirm: Boolean)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.custom_dialog_success_view)
        setCanceledOnTouchOutside(false)
        /**设置弹窗的宽度*/
        val m = window?.windowManager
        val d = m?.defaultDisplay
        val p = window?.attributes
        val size = Point()
        d?.getSize(size)
        p?.width = size.x
        p?.height = size.y
        window?.attributes = p
        window?.setBackgroundDrawable(mContext.getDrawable(R.drawable.custom_dialog2_bg_mengceng))
        val okBtn = findViewById<Button>(R.id.affirm_btn)
        okBtn.setOnClickListener(this)
    }

    override fun onClick(view: View) {
        listener?.onClick(this, true)
    }
}